package com.fd.controller;

import com.fd.bean.Demo;
import com.fd.service.DemoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController//声明了一个rest风格的controller
public class DemoController {
    @Autowired
    private DemoService demoService;

    @RequestMapping(value = "/likeName/{name}")
    public List<Demo> likeName(@PathVariable("name") String name) {
        return demoService.likeName(name);
    }

    @RequestMapping("/save")
    public Demo save(){
        Demo demo = new Demo();
        demo.setName("张三");
        System.out.println("demo = " + demo);
        demoService.save(demo);
        return demo;
    }
}
